<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>报修管理系统</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="/css/font.css">
        <link rel="stylesheet" href="/css/xadmin.css">
        <script src="./lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="/js/xadmin.js"></script>
        <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
        <!--[if lt IE 9]>
          <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
          <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
    <body>
        <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                    	<!-- 条件搜索 -->
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5">
                                <div class="layui-input-inline layui-show-xs-block">
                                    <select name="contrller" id="prod_type">
                                        <option value="">产品类型</option>
                                        <option value="1">台式机</option>
                                        <option value="2">笔记本</option>
                                        <option value="3">投影仪</option>
                                        <option value="4">打印机</option>
                                        <option value="5">其他</option>
                                    </select>
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <button class="layui-btn"  id="search" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
                                </div>
                            </form>
                        </div>
                        <div class="layui-card-header">
<!--                             <button class="layui-btn layui-btn-danger" onclick="delAll()"><i class="layui-icon"></i>批量删除</button> -->
<!--                             <button class="layui-btn" onclick="xadmin.open('添加用户','./eqpt-add.html',600,400)"><i class="layui-icon"></i>添加</button> -->
                        </div>
                        <!-- 设备信息 -->
                        <div class="layui-card-body layui-table-body layui-table-main">
                            <table class="layui-table layui-form">
                                <thead>
                                  <tr>
<!--                                     <th> -->
<!--                                       <input type="checkbox" lay-filter="checkall" name="" lay-skin="primary"> -->
<!--                                     </th> -->
<!--                                     <th>设备编号</th> -->
                                    <th>报修记录编号</th>
                                    <th>设备类型</th>
                                    <th>设备名</th>
                                    <th>缺少零件</th>
                                    <th>机器故障现象</th>
                  					<th>故障类型</th>
                                    <th>机器外观检查</th>
                                    <th>开机口令</th>
                                    <th>重要资料</th>
                                    <th>HDD</th>
                                    <th>内存</th>
                                    <th>外置PC卡</th>
                                    <th>AC适配器</th>
                                    <th>电池</th>
                                    <th>外接光驱</th>
                                    <th>其他</th>
                                    <th>操作</th>
                                </thead>
                                <tbody id="eqptInfos">
                                  <tr>
                                    <th colspan='17' style="text-align:center;">暂无记录</th> 
                                  </tr>
                                </tbody>
                            </table>
                        </div>

                       	<!-- 分页导航 -->
                        <div class="layui-card-body ">
                            <div class="page">
                                <div id="nav">
                               
                                </div>
                            </div>
                        </div>
                        <script type="text/javascript">
                        		var page1 = 1;
                        		var psize1 = 5;
                        		
                            	//删除记录
                            	function deleteEqpt(eqptId){
                        			$.ajax({
                        				type:"get",
                        				url:"http://localhost:8080/eqpt/deleteEqptById.do",
                        				data:{
                        					"id":eqptId,
                        				},
                        				dataType:"json",
                        				success:function(response){
                        					if(response.status == 0){
                        						window.location.reload();
                        					}
                        				}
                        			})
                            	}
                        		
                        		
                            	function page(pn,ps){
                            		console.log("pn"+pn);
                            		console.log("ps"+ps);
                            		page1 = pn;
                            		psize1 = ps;
                            		//拿到当前页面的链接地址
                                	var val = window.location.href;
                                	// 拿到链接地址传递的报修id
                                	var repairId = val.split("?")[1].split("=")[1];
                                	if(null == repairId || undefined == repairId){
                                		alert("系统出错,请重新选择");
                                		window.location.go(-1);
                                	}
                            		$.ajax({
                                		type:"get",
                                		url:"http://localhost:8080/eqpt/queryEqptByProdType.do",
                                		//url:"eqpt/queryEqptByProdType"+repairId,
                                		data:{
                                			"pageNum":pn,
                                			"pageSize":ps,
                                			"repairId":repairId,
                                			"prod_type":$("#prod_type").val()
                                		},
                                		dataType:"json",
                                		success:function(response){
                                			console.log(response);
                                			var data = response.data.list;
                                			$("#eqptInfos").empty();	
                                			//分页数据
                                			for(var i=0;i<data.length;i++){
                                				var tr = $("<tr></tr>");
//                                  				tr.append("<td><input type='checkbox' name='id' value='"+data[i].id+"' lay-skin='primary'></td>");
//                                     			tr.append("<td>"+data[i].id+"</td>");
                                    			tr.append("<td>"+data[i].repairId+"</td>");
                                 				if(data[i].prodType==0){
                                 					tr.append("<td>无记录</td>");
                                 				}
                                 				if(data[i].prodType==1){
                                 					tr.append("<td>台式机</td>");
                                 				}
                                 				if(data[i].prodType==2){
                                 					tr.append("<td>笔记本</td>");
                                 				}
                                 				if(data[i].prodType==3){
                                 					tr.append("<td>投影仪</td>");
                                 				}
                                 				if(data[i].prodType==4){
                                 					tr.append("<td>打印机</td>");
                                 				}
                                 				if(data[i].prodType==5){
                                 					tr.append("<td>其他</td>");
                                 				}
                                 				if(data[i].machBrd==null || data[i].machBrd==''){
                                 					tr.append("<td>无记录</td>");
                                 				}else{
                                 					tr.append("<td>"+data[i].machBrd+" "+data[i].machType+" "+data[i].serialNumb+"</td>");
                                 				}
                                				if(data[i].misPart==null || data[i].misPart==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].misPart+"</td>");
                                				}
                                				if(data[i].machFailure==null || data[i].machFailure==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].machFailure+"</td>");
                                				}
                                				if(data[i].faultType==0){
                                					tr.append("<td>无法判定</td>");
                                				}
                                				if(data[i].faultType==1){
                                					tr.append("<td>固定性故障</td>");
                                				}
                                				if(data[i].faultType==2){
                                					tr.append("<td>间隙性故障</td>");
                                				}
                                				if(data[i].machAppera==null || data[i].machAppera==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].machAppera+"</td>");
                                				}
                                				if(data[i].machPwd==null || data[i].machPwd==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].machPwd+"</td>");
                                				}
                                				if(data[i].vitalInfo==0){
                                					tr.append("<td>无记录</td>");
                                				}
                                				if(data[i].vitalInfo==1){
                                					tr.append("<td>有</td>");
                                				}
                                				if(data[i].vital_info==2){
                                					tr.append("<td>无</td>");
                                				}
                                				if(data[i].hdd==null || data[i].hdd==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].hdd+"</td>");
                                				}
                                				if(data[i].memory==null || data[i].memory==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].memory+"</td>");
                                				}                                				
                                				if(data[i].pamcia==null || data[i].pamcia==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].pamcia+"</td>");
                                				}
                                				if(data[i].acadapter==null || data[i].acadapter==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].acadapter+"</td>");
                                				}
                                				if(data[i].battery==null || data[i].battery==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].battery+"</td>");
                                				}
                                				if(data[i].exDriver==null || data[i].exDriver==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].exDriver+"</td>");
                                				}
                                				if(data[i].other==null || data[i].other==''){
                                					tr.append("<td>无记录</td>");
                                				}else{
                                					tr.append("<td>"+data[i].other+"</td>");
                                				}
                                				tr.append("<td class='td-manage'><a title='编辑'  href='rec-eqpt-edit.html?id="+data[i].id+"'><i class='layui-icon'>&#xe642;</i></a><a title='删除' onclick='deleteEqpt("+data[i].id+")' href='javascript:;'><i class='layui-icon'>&#xe640;</i></a></td>")
                                				$("#eqptInfos").append(tr);	
                                			}
                                			// 分页导航栏
                                			var navs = response.data.navigatepageNums;
                                			$("#nav").empty();
                                			$("#nav").append("<a class='prev' onclick='page("+(page1-1)+","+psize1+")'>&lt;&lt;</a>");
                                			for(var i=0;i<navs.length;i++){
                                				$("#nav").append("<a class='num'  onclick='page("+navs[i]+","+psize1+")'>"+navs[i]+"</a>");
                                			}
                                			$("#nav").append("<a class='next' onclick='page("+(page1+1)+","+psize1+")' >&gt;&gt;</a>");
                                		}
                                	})
                            	}
                            	$("#search").click(function(){
                            		page(page1,psize1);
                            		return false;
                            	})
                            	$(function(){
                            		page(page1,psize1);
                            	})
                            	
                    	</script>

                    </div>
                </div>
            </div>
        </div> 
    </body>
    <script>
      layui.use(['laydate','form'], function(){
        var laydate = layui.laydate;
        var  form = layui.form;
        
        //执行一个laydate实例
        laydate.render({
          elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
          elem: '#end' //指定元素
        });

      });
    </script>
</html>